package com.young.shop_admin.controller;

import com.young.shop_admin.pojo.entity.Order;
import com.young.shop_admin.pojo.vo.OrderGoodsDetailVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/orderDetail")
public class OrderDetailController extends BaseController {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //跨域
        resp.setHeader("Access-Control-Allow-Origin", "http://localhost:63342");
        //获取商品id
        Order order = convertParamsToEntity(req, Order.class);
        Integer id = order.getId();
        //通过id修改产品状态,查询订单商品详细
        try {
            List<OrderGoodsDetailVO> orderGoodsDetailVOS = orderList.checkOrderDetail(id);
            writerSuccessResult(orderGoodsDetailVOS, resp);
        } catch (Exception e) {
            String errorMsg = e.getMessage();
            writerErrorResult(errorMsg, resp);
        }
    }
}
